"""
输入验证工具
"""
import re
from typing import Any, Union


def validate_email(email: str) -> bool:
    """
    验证邮箱格式
    """
    pattern = r"^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$"
    return re.match(pattern, email) is not None


def validate_phone(phone: str) -> bool:
    """
    验证手机号格式
    """
    pattern = r"^1[3-9]\d{9}$"
    return re.match(pattern, phone) is not None


def validate_number(value: Union[int, float], min_val: Any = None, max_val: Any = None) -> bool:
    """
    验证数字范围
    """
    if min_val is not None and value < min_val:
        return False
    if max_val is not None and value > max_val:
        return False
    return True